package leedcode_path.shuzhu;



import java.sql.PreparedStatement;

public class search704 {
    public int search(int[] nums, int target) {
        int flag=-1;
        int left=-1;
        int right=nums.length;

        while (left+1!=right){
            flag=(left+right)/2;
            if (nums[flag]<target){
                left=flag;
            }
            else {
                right=flag;
            }
       }
        if (right==nums.length) return -1;
        if (nums[right]==target){
            return right;
        }
        else{
            return -1;
        }


}


    public static void main(String[] args) {
        int[] nums=new int[]{-1,0,3,5,9,12};
        search704 search =new search704();
        search.search(nums, 13);
        System.out.println(search.search(nums, 13));

    }



   }





